package com.cfh.springcloudsleuthdemo.web.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


@RestController
public class DemoController {

    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @GetMapping("")
    public String index() {
        String returnValue = "Hello,World";
        logger.info("{} index() : {}", getClass().getSimpleName(), returnValue);
        return returnValue;
    }


    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/toZuul")
    public Object toZuul() {
        logger.info("spring-cloud-sleuth#toZuul");
        return restTemplate.getForObject("http://spring-cloud-zuul/person-client/person/findAll",
                Object.class);
    }
}
